/*****************************************************************************
 * Open MCT, Copyright (c) 2014-2016, United States Government
 * as represented by the Administrator of the National Aeronautics and Space
 * Administration. All rights reserved.
 *
 * Open MCT is licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 * Open MCT includes source code licensed under additional open source
 * licenses. See the Open Source Licenses file (LICENSES.md) included with
 * this source code distribution or the Licensing information page available
 * at runtime from the About dialog for additional information.
 *****************************************************************************/

ul.tree {
    @include menuUlReset();
    @include user-select(none);
    li {
        display: block;
        position: relative;
    }
    ul.tree {
        margin-left: $treeVCW + $interiorMargin;
    }
}

.tree-item,
.search-result-item {
    @extend .l-flex-row;
    box-sizing: border-box;
    border-radius: $basicCr;
    @include transition(background-color, 0.25s);
    font-size: 0.8rem;
    height: $menuLineH;
    line-height: $menuLineH;
    margin-bottom: $interiorMarginSm;
    padding: 0 $interiorMarginSm;
    position: relative;

    .flex-elem {
        height: inherit !important;
        line-height: inherit !important;
    }

    .view-control {
        color: $colorItemTreeVC;
        font-size: 0.75em;
        margin-right: $interiorMargin;
        height: 100%;
        line-height: inherit;
        width: $treeVCW;
        &.has-children {
            &:before {
                position: absolute;
                @include trans-prop-nice(transform, 100ms);
                content: "\e904";
                @include transform-origin(center);
            }
            &.expanded:before {
                @include transform(rotate(90deg));
            }
        }
    }

    .t-object-label {
        line-height: $menuLineH;
        .t-item-icon {
            @include txtShdwSubtle($shdwItemTreeIcon);
            font-size: $treeTypeIconH;
            color: $colorItemTreeIcon;
            width: $treeTypeIconW;
        }
        .t-title-label {
            @include ellipsize();
        }
    }

    &.selected {
        background: $colorItemTreeSelectedBg !important;
        color: $colorItemTreeSelectedFg !important;
        .view-control {
            color: $colorItemTreeSelectedVC;
        }
        .t-object-label .t-item-icon {
            color: $colorItemTreeSelectedFg;
        }
    }

    &:not(.loading) {
        cursor: pointer;
    }

    .context-trigger {
        $h: 0.9rem;
        top: -1px;
        position: absolute;
        right: $interiorMarginSm;
        .invoke-menu {
            font-size: 0.75em;
            height: $h;
            line-height: $h;
        }
    }
}

body.desktop {
    .tree-item,
    .search-result-item {
        .view-control {
            &:hover {
                color: $colorItemTreeVCHover !important;
            }
        }
        &:not(.selected) {
            &:hover {
                background: $colorItemTreeHoverBg;
                color: $colorItemTreeHoverFg;
                .t-item-icon {
                    color: $colorItemTreeIconHover;
                }
            }
        }
    }
}

mct-representation {
    &.s-status-pending {
        .t-object-label {
            .t-item-icon {
                &:before {
                    border-color: rgba($colorItemTreeIcon, 0.25);
                    border-top-color: rgba($colorItemTreeIcon, 1.0);
                }
            }
        }
    }
}

.tree .s-status-editing,
.search-results .s-status-editing {
    // Item is being edited
    .tree-item,
    .search-result-item {
        background: $colorItemTreeEditingBg;
        pointer-events: none;
        &:before {
            // Pencil icon
            @extend .ui-symbol;
            @include pulse($dur: 1s, $opacity0: 0.25);
            color: $colorItemTreeEditingFg;
            content: $glyph-icon-pencil;
            margin-right: $interiorMarginSm;
        }
        .t-object-label {
            .t-item-icon,
            .t-title-label {
                color: $colorItemTreeEditingFg;
                text-shadow: none;
            }
            .t-title-label {
                font-style: italic;
            }
        }
        .view-control, + .tree-item-subtree {
            display: none;
        }

        &.selected {
            .t-title-label,
            .t-item-icon,
            &:before {
                color: rgba($colorItemTreeSelectedFg, 0.5);
            }
        }
    }
}
